# 安装MariaDB 安装依赖库、编译工具
yum install -y apr* autoconf automake bison bzip2 bzip2* \
cloog-ppl compat* cpp curl curl-devel fontconfig fontconfig-devel \
freetype freetype* freetype-devel gcc gcc-c++ gtk+-devel gd gettext gettext-devel glibc kernel kernel-headers keyutils \
keyutils-libs-devel krb5-devel libcom_err-devel libpng libpng-devel libjpeg* libsepol-devel libselinux-devel libstdc++-devel \
libtool* libgomp libxml2 libxml2-devel libXpm* libtiff libtiff* make mpfr ncurses* ntp openssl openssl-devel patch pcre-devel \
perl php-common php-gd policycoreutils telnet t1lib t1lib* nasm nasm* zlib-devel gd-devel \
&&
# 安装CMake
cd /usr/local/src && /usr/local/src/configure && make && make install \
&&
# 添加mysql运行组及用户、创建数据库数据文件文件夹并授予合适权限
groupadd mysql && useradd -g mysql mysql -s /bin/false && mkdir -p /data/mysql && chown -R mysql:mysql /data/mysql \
&&
sed -i  "46cbasedir=/usr/local/mysql" /etc/rc.d/init.d/mysqld && sed  -i  "47cdatadir=/data/mysql" /etc/rc.d/init.d/mysqld
echo 'export PATH=$PATH:/usr/local/mysql/bin' >> /etc/profile && source /etc/profile
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql &&
ln -s /usr/local/mysql/include/mysql /usr/include/mysql &&
mkdir /var/lib/mysql &&
ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
service mysqld start
echo "数据库启动成功....请使用命令: mysql_secure_installation 设置数据库"

echo "现在开始安装nginx"
groupadd www && useradd -g www www -s /bin/false

cd /usr/local/src &&
mkdir /usr/local/pcre &&
tar -zxvf pcre-8.35.tar.gz &&
cd pcre-8.35 &&
./configure --prefix=/usr/local/pcre &&
make && make install

cd /usr/local/src &&
mkdir /usr/local/openssl &&
tar -zxvf openssl-1.0.1i.tar.gz &&
cd openssl-1.0.1i &&
./config --prefix=/usr/local/openssl &&
make && make install &&
echo 'export PATH=$PATH:/usr/local/openssl/bin'>>/etc/profile &&
source /etc/profile

cd /usr/local/src &&
mkdir /usr/local/zlib &&
tar zxvf zlib-1.2.8.tar.gz &&
cd zlib-1.2.8 &&
./configure --prefix=/usr/local/zlib &&
make && make install

cd /usr/local/src &&
tar -zxvf  nginx-1.6.1.tar.gz &&
cd nginx-1.6.1 &&
./configure --prefix=/usr/local/nginx \
--without-http_memcached_module \
--user=www \
--group=www \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_gzip_static_module \
--with-openssl=/usr/local/src/openssl-1.0.1i \
--with-zlib=/usr/local/src/zlib-1.2.8 \
--with-pcre=/usr/local/src/pcre-8.35 \
--with-http_stub_status_module \
--with-http_sub_module \ &&
make && make install &&
echo "安装NGINX完毕！"

chown www:www /etc/rc.d/init.d/nginx &&
chkconfig nginx on &&
/etc/rc.d/init.d/nginx start

./configure --prefix=/usr/local/libgd --enable-shared --with-jpeg=/usr/local/jpeg  --with-freetype=/usr/local/freetype --with-fontconfig=/usr/local/freetype --with-xpm=/usr/ --with-tiff=/usr/local/tiff --with-vpx=/usr/local/libvpx &&
make && make install


#
./configure  --as=yasm --prefix=/usr/local/libvpx --enable-shared --enable-vp9  && make && make install





./configure --prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-mysql-sock=/tmp/mysql.sock \
--with-pdo-mysql=/usr/local/mysql \
--with-gd \
--with-jpeg-dir=/usr/local/jpeg \
--with-freetype-dir=/usr/local/freetype \
--with-xpm-dir=/usr/ \
--with-vpx-dir=/usr/local/libvpx/ \
--with-zlib-dir=/usr/local/zlib \
--with-t1lib=/usr/local/t1lib \
--with-iconv \
--enable-libxml \
--enable-xml \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--enable-opcache \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--enable-ftp \
--enable-gd-native-ttf \
--with-openssl \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--without-pear \
--with-gettext \
--enable-session \
--with-mcrypt \
--with-curl \
--enable-exif \
--enable-ctype &&
make && make install